/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package argtrust.apiexamples;

import java.lang.System;
import java.util.Collection;

import aima.core.logic.fol.parsing.FOLParser;
import aima.core.logic.fol.parsing.ast.Sentence;
import aima.core.logic.fol.domain.FOLDomain;
import aima.core.logic.fol.Connectors;

import argtrust.logic.FOLNaturalDeduction;
import argtrust.logic.FOLKnowledgeBase;
import argtrust.logic.InferenceRule;
import argtrust.logic.InferenceNode;
import argtrust.argsys.ArgumentationSystem;
import argtrust.argsys.ArguingNode;
import argtrust.belief.BeliefBase;
import argtrust.trustnet.Agent;
import argtrust.trustnet.TrustNet;
import argtrust.trustnet.TrustNode;
import argtrust.tidal.TidalTrust;
import argtrust.tidal.TidalTrustBelief;
import argtrust.trustnet.ITrustSemantics;
import argtrust.belief.ITrustBeliefSemantics;
import argtrust.argsys.IBeliefArgumentSemantics;
import argtrust.argsys.MinBeliefArgument;
import argtrust.argsys.IArgumentationSemantics;
import argtrust.argsys.LabelGroundedSemantics;


import argtrust.argtrustgraph.ArgTrustGraph;
import argtrust.xml.XMLTrustBeliefReader;

/**
 *
 * @author Yuqing Tang
 */
public class JCLXMLExamples {

    public static void main(String[] args) {
        XMLTrustBeliefReader reader = new XMLTrustBeliefReader();
        reader.readFile("/home/tang/NetBeansProjects/ArgTrust/XML-samples/jcl.xml");
        //Argumentation system:
        BeliefBase bb = reader.getBeliefBase();
        FOLKnowledgeBase kb = new FOLKnowledgeBase();
        kb.acceptKnowledgeBase(bb.getFactSet(), bb.getRuleSet());
        ArgumentationSystem arg_sys = new ArgumentationSystem(kb);
//        FOLNaturalDeduction deduct_sys = arg_sys.getDeductionSys();
//        InferenceNode inf = deduct_sys.getInferenceNet(fol.parse("NOT Watch(hce)"));
//        while (inf != null) {
//            System.out.println("found: ");
//            inf.debug_print(System.out);
//            inf = deduct_sys.getNextInferenceNet(inf);
//        }
        ArguingNode watch_hce_arggraph = arg_sys.getArguingNode(reader.getFolParser().parse("Watch(hce)"));
//        ArguingNode not_watch_hce_arggraph =
//        arg_sys.getArguingNode(fol.parse("NOT Watch(hce)"));

        watch_hce_arggraph.debug_print(System.out);

        ArgTrustGraph gv = new ArgTrustGraph();
        gv.setArgSys(arg_sys);
        gv.setBeliefBase(reader.getBeliefBase());
        TrustNet trust_net = reader.getTrustnet();
        gv.setTrustNet(trust_net);
        TidalTrust trust_sem = new TidalTrust(trust_net, 0);
        gv.setTrustSemantics(trust_sem);

        ITrustBeliefSemantics trust_belief_sem = new TidalTrustBelief(bb, trust_sem);
        gv.setTrustBeliefSemantics(trust_belief_sem);

        IBeliefArgumentSemantics arg_belief_sem = new MinBeliefArgument(trust_belief_sem);
        gv.setArgumentBeliefSemantics(arg_belief_sem);

        IArgumentationSemantics argumentation_sem = new LabelGroundedSemantics(arg_sys, arg_belief_sem);
        gv.setArgumentationSemantics(argumentation_sem);


        gv.openFile("/home/tang/temp/jcl-xml.dot");
        gv.draw(watch_hce_arggraph, trust_net.getTrustNode("john"));
//        gv.draw(arg_sys.getAllNodes(), trust_net.getTrustNodes());
        gv.close();

    }
}
